<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>订单详情</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link type="text/css" rel="stylesheet" media="screen" href="__FONT__/css/style.css"/>
    <link type="text/css" rel="stylesheet" media="screen" href="__FONT__/css/media.css"/>
    <script type="text/javascript" src="__FONT__/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
	  $(function(){
		  $(".pay_discount h1").click(function(){
			  $(".pay_show").slideToggle();
			  });
		  $(".pay_show dd").click(function(){
			  $(this).children('label').after('<i></i>');
			  $(this).siblings().children('i').hide();
			  $(".add_pay").html($(this).html());
			  $(".pay_show").slideToggle('slow');
			 // alert($(this).html())
			  });	  
	  });
	</script>
    <style>
		.hide{display:none;}
	</style>
</head>
<body style="background:#f7f7f9;">
	<include file="Public/customHeader" title="订单详情" url="{:U('/Order/userOrder')}"/>
 	<section class="beauty_sec beauty_pay">
      <div class="pay_main hackpay">
        <h1>{$beautyParlor.name}<eq name="order.status" value="2">
                   	<label>待付款</label><label class="hide" style="display:none;">已取消</label>
                    </eq>
                    <eq name="order.status" value="1"><label>待消费</label></eq>
                    <eq name="order.status" value="5"><label>已取消</label></eq>
                    <eq name="order.status" value="4"><label>已完成</label></eq>
                    <eq name="order.status" value="3"><label>服务中</label></eq></h1>
        <h2>项目：<span>{$order.service_name}</span><label>￥{$order.price}</label></h2>
        <div class="pay_myself">
          <if condition="$beautician['profile_img']">
	       <img src="__UPLOADS__/Profile/{$beautician.profile_img}">
	       <else />
	       <img src="__FONT__/images/defaultProfile.png">
	       </if>
          <dd>
            <strong><span>美&nbsp;&nbsp;容&nbsp;&nbsp;师：</span><label>{$beautician.name}</label></strong>
            <strong><span>服务时间：</span><label>{$order.service_time}分钟</label></strong>
          </dd>
        </div>
        <div class="pay_yourself payhei">
            <strong><span>预&nbsp;&nbsp;约&nbsp;&nbsp;人：</span><label>{$user.username}</label><a>（{$user.mobile}）</a></strong>
            <strong><span>预约时间：</span><label>{$order.order_time|date="Y-m-d H:i",###}</label></strong>
            <strong><span>服务地址：</span><label class="mydress">{$order.service_address}</label></strong>
        </div>
      </div>
      
      <div class="pay_discount paydetail">
      	<if condition="$coupon">
        <dd class="add_pay">优&nbsp;&nbsp;惠&nbsp;&nbsp;券：<span>{$coupon.coupon_title}</span><label>-￥<if condition="$coupon ['c_type'] neq 2">
          {$coupon.money_reduce}
          <else />
          {$coupon.money_amount}
          </if></label></dd>
        </if>
        <dd class="add_pay">支付方式：<label>微信支付</label></dd>
      </div>
      
      <div class="pay_method payme">
        <strong>客服电话：<i>{$format_service_hotline}</i></strong>
        <strong>订&nbsp;&nbsp;单&nbsp;&nbsp;号：<i>{$order.order_number}</i></strong>
        <strong>创建时间：<i>{$order.created|date="Y-m-d H:i:s",###}</i></strong>
        <eq name="order.status" value="2">
        <font>订单会为您保留10分钟，请尽快完成支付，超时未支付的订单会自动取消。</font>
        </eq>
        
        <eq name="order.status" value="1">
        <strong><a href="{:U('moretips')}">订单变更相关说明，查看详情></a></strong>
        </eq>
      </div>
	</section>
    <footer class="pay_going">
    	<dd><span>实付金额：</span><label >￥<font id="priceShow">{$pay}</font></label></dd>
        <eq name="order.status" value="2">
        <div class="btn_pay againorder">
        <a href="javascript:void(0);" class="channel_btn cancelOrder">取消订单</a>
        <a href="{:U('Order/rePay/id/'.$order ['id'])}" class="mrs_btn">去支付</a>
        </eq>
        <eq name="order.status" value="1">
        <div class="btn_pay againorder">
<!--         <a href="{:U('/Order/orderInfo/id/'.$order['id'])}" class="mrs_btn">查看订单</a> -->
        </eq>
        <eq name="order.status" value="5">
        <div class="btn_pay paychancle againorder">
        <a href="" class="channel deleteOrder"></a></li>
        <a href="{:U('ServiceItem/reOrder/id/'.$order['id'])}" class="mrs_btn">再次预约</a>
        </eq>
        <eq name="order.status" value="4">
        <div class="btn_pay againorder">
        <a href="{:U('ServiceItem/reOrder/id/'.$order['id'])}" class="channel_btn">再次预约</a>
        <a href="{:U('Comments/comment/id/'.$order['id'])}" class="mrs_btn">去评价</a>
        </eq>
        <eq name="order.status" value="3"></eq>
       </div>
    </footer>
    <script>
    $(function () {
    	var ajaxDeleteOrder, ajaxCancelOrder, id='{$order.id}';
    	
    	function deleteOrder(elem) {
    		var _this = $(elem),
			wrap = $(_this).parents('div.my_order');
    		
    		if (ajaxDeleteOrder && ajaxDeleteOrder.state() == 'pending') {
    			return false;
    		}
    		
    		ajaxDeleteOrder = $.ajax({
    			url: '{:U("Order/delete")}',
    			data:{id: id},
    			dataType: 'json',
    			success: function (result) {
    				if (result.status) {
    					window.location.href = '{:U("Order/userOrder")}';
    				} else {
    					return false;
    				}
    			},
    			error: function () {
    				alert('请求中断，稍候再试');
    			}
    		});
    	}
    	
    	var deleteDom = '<a href="javascript:void(0);" class="channel deleteOrder" ></a>'
        		+'<a href="{:U(\'ServiceItem/reOrder/id/\'.$order[\'id\'])}" class="mrs_btn" >再次预约</a>';
    	$('.cancelOrder').click(function (e) {
    		if (confirm('确定要取消该订单吗？')) {
	    		var _this = $(this),
	    			wrap = $(_this).parents('div.my_order');
	    		
	    		if (ajaxCancelOrder && ajaxCancelOrder.state() == 'pending') {
	    			return false;
	    		}
	    		
	    		ajaxCancelOrder = $.ajax({
	    			url: '{:U("Order/cancel")}',
	    			data:{id: id},
	    			dataType: 'json',
	    			success: function (result) {
						if (result.status) {
							var btnContainer = $(_this).parents('div.btn_pay')
								.empty().append(deleteDom);
							
							$(btnContainer).addClass('paychancle').find('.deleteOrder').click(function (e) {
					    		if (confirm('确定要删除该订单吗？')) {
					        		deleteOrder(this);
					    		}
					    		return false;
					    	});
							
// 							$(wrap).find('h1 label.hide').show().prev().hide();
// 				    		$(_this).parents('li').siblings('.hide').show().siblings().not('.hide').remove();
						} else {
							alert(result.message);
							return false;
						}
					},
	    			error: function () {
	    				alert('请求中断，稍候再试');
	    			}
	    		});
    		}
    		return false;
    	});
    	
    	$('.deleteOrder').click(function (e) {
    		if (confirm('确定要删除该订单吗？')) {
        		deleteOrder(this);
    		}
    		return false;
    	});
    })
    </script>
</body>
</html>